#include "StdAfx.h"
#include "CircuitEllipse.h"


CCircuitEllipse::CCircuitEllipse(void)
{
	m_dblPosX = 0;
	m_dblPosY = 0;
	m_dblRadiusX = 0;
	m_dblRadiusY = 0;
	m_dblBorderWidth = 0;
	m_dblBorderColor[0] = 0;
	m_dblBorderColor[1] = 0;
	m_dblBorderColor[2] = 0;
	m_bIsFill = false;
	m_dblFillColor[0] = 0;
	m_dblFillColor[1] = 0;
	m_dblFillColor[2] = 0;
	m_bSelected = false;
	m_linePattern = SOLID_LINE;
}

CCircuitEllipse::CCircuitEllipse(const CCircuitEllipse *pEntityObj)
	: CCircuitUnit(pEntityObj)
{
	m_dblPosX = pEntityObj->GetPosX();
	m_dblPosY = pEntityObj->GetPosY();
	m_dblRadiusX = pEntityObj->GetRadiusX();
	m_dblRadiusY = pEntityObj->GetRadiusY();
	m_dblBorderWidth = pEntityObj->GetBorderWidth();
	m_dblBorderColor[0] = pEntityObj->GetBorderColorR();
	m_dblBorderColor[1] = pEntityObj->GetBorderColorG();
	m_dblBorderColor[2] = pEntityObj->GetBorderColorB();
	m_bIsFill = pEntityObj->IsFill();
	m_dblFillColor[0] = pEntityObj->GetFillColorR();
	m_dblFillColor[1] = pEntityObj->GetFillColorG();
	m_dblFillColor[2] = pEntityObj->GetFillColorB();
	m_bSelected = pEntityObj->IsSelect();
	m_linePattern = pEntityObj->GetLinePattern();
}

CCircuitEllipse::CCircuitEllipse(CICircuit *pParentEnt)
	: CCircuitUnit(pParentEnt)
{
	m_dblPosX = 0;
	m_dblPosY = 0;
	m_dblRadiusX = 0;
	m_dblRadiusY = 0;
	m_dblBorderWidth = 0;
	m_dblBorderColor[0] = 0;
	m_dblBorderColor[1] = 0;
	m_dblBorderColor[2] = 0;
	m_bIsFill = false;
	m_dblFillColor[0] = 0;
	m_dblFillColor[1] = 0;
	m_dblFillColor[2] = 0;
	m_bSelected = false;
	m_linePattern = SOLID_LINE;
}

CCircuitEllipse::~CCircuitEllipse(void)
{
}

void CCircuitEllipse::Serialize(CArchive & ar)
{
	if (ar.IsStoring())
	{
		ar << m_dblPosX;
		ar << m_dblPosY;
		ar << m_dblRadiusX;
		ar << m_dblRadiusY;
		ar << m_dblBorderWidth;
		ar << m_dblBorderColor[0];
		ar << m_dblBorderColor[1];
		ar << m_dblBorderColor[2];
		ar << m_dblFillColor[0];
		ar << m_dblFillColor[1];
		ar << m_dblFillColor[2];
		ar << m_bIsFill;
		ar << m_bSelected;
		ar << m_linePattern;
	}
	else
	{
		ar >> m_dblPosX;
		ar >> m_dblPosY;
		ar >> m_dblRadiusX;
		ar >> m_dblRadiusY;
		ar >> m_dblBorderWidth;
		ar >> m_dblBorderColor[0];
		ar >> m_dblBorderColor[1];
		ar >> m_dblBorderColor[2];
		ar >> m_dblFillColor[0];
		ar >> m_dblFillColor[1];
		ar >> m_dblFillColor[2];
		ar >> m_bIsFill;
		ar >> m_bSelected;

		if ( CObj::m_lFileVersion >= 118 )
		{
			int nLinePatt(0);
			ar >> nLinePatt;
			m_linePattern = (eLinePattern)nLinePatt;
		}
	}

	CCircuitUnit::Serialize(ar);
}

CObj *CCircuitEllipse::Clone() const
{
	return new CCircuitEllipse(this);
}

void CCircuitEllipse::Transform(const CMatrix transf)
{

}

bool CCircuitEllipse::GetBox(double & dblLeft, double & dblBottom, double & dblRight, double & dblTop) const
{
	return false;
}

void CCircuitEllipse::Clear()
{

}

void CCircuitEllipse::CopyDisplayObj(long lSourceLayerId, long lDestLayerId)
{
	CEntityObj::CopyDisplayObj(lSourceLayerId, lDestLayerId);
}

void CCircuitEllipse::DeleteDisplayObj(long lLayerId)
{
	CEntityObj::DeleteDisplayObj(lLayerId);
}

CDisplayObj *CCircuitEllipse::CreateDisplayObj(long lLayerId)
{
	CCircuitEllipseDisObj *pElliDis = new CCircuitEllipseDisObj(this);
	pElliDis->SetLayerId(lLayerId);
	return pElliDis;
}

void CCircuitEllipse::CalcBox()
{
	m_minX = m_dblPosX - m_dblRadiusX;
	m_maxX = m_dblPosX + m_dblRadiusY;
	m_minY = m_dblPosY - m_dblRadiusY;
	m_maxY = m_dblPosY + m_dblRadiusY;
}

eCircuitUnitEntType CCircuitEllipse::GetUnitType() const
{
	return CIRCUIT_ELLIPSE;
}

double CCircuitEllipse::GetPosX() const
{
	return m_dblPosX;
}

double CCircuitEllipse::GetPosY() const
{
	return m_dblPosY;
}

double CCircuitEllipse::GetRadiusX() const
{
	return m_dblRadiusX;
}

double CCircuitEllipse::GetRadiusY() const
{
	return m_dblRadiusY;
}

double CCircuitEllipse::GetBorderWidth() const
{
	return m_dblBorderWidth;
}

eLinePattern CCircuitEllipse::GetLinePattern() const
{
	return m_linePattern;
}

double CCircuitEllipse::GetBorderColorR() const
{
	return m_dblBorderColor[0];
}
double CCircuitEllipse::GetBorderColorG() const
{
	return m_dblBorderColor[1];
}
double CCircuitEllipse::GetBorderColorB() const
{
	return m_dblBorderColor[2];
}

bool CCircuitEllipse::IsSelect() const
{
	return m_bSelected;
}

bool CCircuitEllipse::IsFill() const
{
	return m_bIsFill;
}

double CCircuitEllipse::GetFillColorR() const
{
	return m_dblFillColor[0];
}

double CCircuitEllipse::GetFillColorG() const
{
	return m_dblFillColor[1];
}

double CCircuitEllipse::GetFillColorB() const
{
	return m_dblFillColor[2];
}

void CCircuitEllipse::SetPosX(double posX) 
{
	m_dblPosX = posX;
}

void CCircuitEllipse::SetPosY(double posY) 
{
	m_dblPosY = posY;
}

void CCircuitEllipse::SetRadiusX(double rad)
{
	m_dblRadiusX = rad;
}

void CCircuitEllipse::SetRadiusY(double rad) 
{
	m_dblRadiusY = rad;
}

void CCircuitEllipse::SetBorderWidth(double dblWidth)
{
	m_dblBorderWidth = dblWidth;
}

void CCircuitEllipse::SetLinePattern(eLinePattern ePatn)
{
	m_linePattern = ePatn;
}

void CCircuitEllipse::SetBorderColorR(double colR) 
{
	m_dblBorderColor[0] = colR;
}

void CCircuitEllipse::SetBorderColorG(double colG)
{
	m_dblBorderColor[1] = colG;
}

void CCircuitEllipse::SetBorderColorB(double colB)
{
	m_dblBorderColor[2] = colB;
}

void CCircuitEllipse::SetSelect(bool bFlag)
{
	m_bSelected = bFlag;
}

void CCircuitEllipse::SetFill(bool bFlag)
{
	m_bIsFill = bFlag;
}

void CCircuitEllipse::SetFillColorR(double colR) 
{
	m_dblFillColor[0] = colR;
}

void CCircuitEllipse::SetFillColorG(double colG)
{
	m_dblFillColor[1] = colG;
}

void CCircuitEllipse::SetFillColorB(double colB)
{
	m_dblFillColor[2] = colB;
}